﻿using System;
using SharpSqlAnalyzer.nodes;
using SharpSqlAnalyzer.pp.processor.type.comm;
using SharpSqlAnalyzer.pp.utils;
using SharpSqlAnalyzer.stmt;

namespace SharpSqlAnalyzer.pp.processor.type.insert
{
	// Token: 0x02000240 RID: 576
	public class InsertValuesParenthsesAdjustProcessor : AbstractProcessor
	{
		// Token: 0x060012F6 RID: 4854 RVA: 0x0031BCF4 File Offset: 0x00319EF4
		public override void process(TParseTreeNode nodeArg)
		{
			TInsertSqlStatement tinsertSqlStatement = nodeArg as TInsertSqlStatement;
			TMultiTargetList values = tinsertSqlStatement.Values;
			this.processValues(values);
			if (tinsertSqlStatement.InsertIntoValues != null && tinsertSqlStatement.InsertIntoValues.Count > 0)
			{
				for (int i = 0; i < tinsertSqlStatement.InsertIntoValues.Count; i++)
				{
					TInsertIntoValue tinsertIntoValue = tinsertSqlStatement.InsertIntoValues[i];
					this.processValues(tinsertIntoValue.TargetList);
				}
			}
		}

		// Token: 0x060012F7 RID: 4855 RVA: 0x0031BD5C File Offset: 0x00319F5C
		private void processValues(TMultiTargetList multiTarget)
		{
			if (multiTarget != null)
			{
				for (int i = 0; i < multiTarget.size(); i++)
				{
					TMultiTarget multiTarget2 = multiTarget.getMultiTarget(i);
					if (multiTarget2.ColumnList != null && multiTarget2.ColumnList.size() > 0 && multiTarget.startToken.astext.Equals("("))
					{
						SourceTokenOperator.removeWhitespaceAndReturnFromEnd(this.Option, multiTarget.startToken);
						SourceTokenOperator.addBefore(this.Option, multiTarget.startToken, SourceTokenOperator.createWhitespaceSourceToken(1));
					}
				}
			}
		}
	}
}
